//#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QtQml>
#include <QDebug>
#include "userfunc.h"

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    //QGuiApplication app(argc, argv);
    QApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/AS_TOOL_UI/imports"); // 添加imports文件路径
    engine.load(QUrl(QStringLiteral("qrc:/AS_TOOL_UI/content/App.qml"))); // 加载QML

    UserFunc myClass(engine.rootObjects()); // 获取QML对象
    app.installNativeEventFilter(myClass.mySerialEvent); // 安装window串口拔插事件

    engine.rootContext()->setContextProperty("myClass", &myClass); // 将C++类添加进QML使用
    engine.rootContext()->setContextProperty("mySerial", myClass.serial_main); // 将C++类添加进QML使用
    engine.rootContext()->setContextProperty("myNetwork", myClass.network_main); // 将C++类添加进QML使用

    //myClass.set_QMLObject(engine.rootObjects()); // 获取QML对象

    return app.exec();
}
